const fetchFile = (data, url, method = "POST") => {
    console.log(data, url)
    //data为参数{name:"xxx",file:"xxx"}
    const form = new FormData();
    form.append(data.name, data.file)
    return new Promise((resolve, reject) => {
        fetch(url, {
            method,
            mode: 'cors',
            cache: 'no-cache',
            body: form
        }).then(res => res.json())
            .then(res => {
                resolve(res)
            }).catch(err => reject(err))
    })
}

export { fetchFile }